package com.bkhech.controller;


import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import com.bkhech.grace.result.GraceJSONResult;
import com.bkhech.pojo.netty.ChatMsg;
import com.bkhech.utils.JsonUtils;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/mq")
@Slf4j
public class MQTestController {

    @Resource
    private RabbitTemplate rabbitTemplate;


    @GetMapping("/send")
    public GraceJSONResult modify() {
        ChatMsg chatMsg = new ChatMsg();
        chatMsg.setMsg("hello world mq!");
        rabbitTemplate.convertAndSend("test_exchange", "wechat.test", JsonUtils.objectToJson(chatMsg));
        return GraceJSONResult.ok();
    }


}

